package com.zjitc.config;

import com.zaxxer.hikari.HikariDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/3/12 14:21
 * @description:
 */
@Configuration
@ComponentScan
public class DataSoutceConfiguration {
  @Bean(destroyMethod = "close")
  public HikariDataSource dataSource(DataSourceProperties prop) {
    HikariDataSource dataSource = new HikariDataSource();

    dataSource.setDriverClassName(prop.getDriverClass());
    dataSource.setJdbcUrl(prop.getJdbcUrl());
    dataSource.setPassword(prop.getPassword());
    dataSource.setUsername(prop.getUsername());

    return dataSource;
  }
}
